package com.example.day10;

public class MT4 implements Runnable {

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(new MT4());
        thread1.setName("thread1");
        Thread thread2 = new Thread(new MT4());
        thread2.setName("thread2");
        Thread thread3 = new Thread(new MT4());
        thread3.setName("thread3");

        thread1.start();
        thread2.start();

        thread2.join();

        thread3.start();

        System.out.println("test");
    }

    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            System.out.println(Thread.currentThread().getName() + " is running...");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
